using System;
using System.Collections.Generic;

namespace LogikBug
{
// ReSharper disable InconsistentNaming
	/// <summary>
	/// 
	/// </summary>
	public static class IListExtensions
// ReSharper restore InconsistentNaming
	{
		/// <summary>
		/// 
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="list"></param>
		/// <param name="predicate"></param>
		/// <returns></returns>
		public static T SingleOrDefault<T>(this IList<T> list, Func<T, bool> predicate)
		{
			for (int i = 0; i < list.Count; i++)
			{
				if (predicate(list[i]))
				{
					return list[i];
				}
			}

			return default(T);
		}
	}
}